#ifndef SINGLETON_H
#define SINGLETON_H

template<typename T>
class Singleton {
public:
    Singleton() { }
    virtual ~Singleton() { }

    static T* getInstance() {
        if(!instance)
            instance = new T();

        return instance;
    }

    static void deleteInstance() {
        if(instance)
            delete instance;
        instance = nullptr;
    }
protected:
    static T* instance;
private:
    Singleton(const Singleton&);
    Singleton& operator=(const Singleton&);

};

template<class T> T* Singleton<T>::instance = nullptr;

#endif // SINGLETON_H
